package cn.gson.crm.convert;

import java.util.Date;

import org.springframework.core.convert.converter.Converter;

public class StringToDateConverter implements Converter<String, Date> {

	@Override
	public Date convert(String source) {
		Boolean flag = source.matches("\\d{1,2}-\\d{1,2}-\\d{4}");
		if (flag) {
			return java.sql.Date.valueOf(source);
		} else {
			throw new IllegalArgumentException("Invalid date format '" + source + "'");
		}
	}
}
